package hutool.base;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.Date;

@Slf4j
public class DateDemo {

    public static void main(String[] args) {
        test01();
    }

    private static void test01() {
        String beginTime = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -20).toString();
        String endTime = DateTime.now().toString();
        log.info("beginTime={}, endTime={}", beginTime, endTime);
    }

    private static void test02() {
        DateTime dateTime = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -1);
        String format = DateUtil.format(dateTime, DatePattern.NORM_DATE_PATTERN);
        System.out.println(format);
        String join = CollUtil.join(Arrays.asList(1, 2, 3, 4, 5), ":");
        System.out.println("join = " + join);
    }
}
